<!doctype html>
<html lang="zh-CN">
<head>
    <title>python导购系统-文章</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <link href="../static/css/index.css" rel="stylesheet">
    <link rel="stylesheet" href="../static/css/css.css">
</head>
<body>
    <ul style="width: 100%;margin-bottom: 90px">
        {% for item in list %}
            <li style="margin: 10px;background-color: #FFFFFF;padding: 5px;width: 100%">
            <a href="{{ item.url }}" style="background-color: #fb4206;color: #FFFFFF">推荐文章 ：{{ item.fields.title }}</a>
             <div id="spread{{ item.fields.id }}" style="margin-top: 3px">
              <p id="content{{ item.fields.id }}"> {{ item.fields.sub}}</p>
             </div>
            <button id="btn{{ item.fields.id }}" onclick="spanClick({{ item.fields.id }},'{{ item.fields.content }}')">展开</button>
            </li>
         {% endfor %}
    </ul>



<div class="end-nav">
    <a href="/main" class="end" id="end"   >
    <span>商城</span>
</a>
<a href="/guangyiguang" class="end" id="end2"  >
    <span>逛一逛</span>
</a>
<a href="/daogou" class="end" id="end3">
    <span>导购</span>
</a>
    <a href="/ars" class="end" id="end3" style="background: red">
    <span>文章</span>
</a>
</div>

<script type="text/javascript">
    function spanClick(id,data) {
    var btn = document.getElementById('btn'+id);
    var content = document.getElementById('content'+id);
        if(data.length==content.textContent.length){
            btn.innerHTML = '展开';
            var end=60;
            content.textContent=data.substring(0,Math.min(end,data.length));
        }else{
            content.textContent=data;
             btn.innerHTML = '收起';
        }
    }

</script>

    <script type="text/javascript">
        var isEnd = false;
        var isLoading = false;
        var page = 1;
        var loading = document.getElementById('load-data');

        function search_check() {
            var formObject = document.getElementById('HSearch');
            var inputQ = formObject['q'];
            if (inputQ.value.length === 0) {
                alert('请输入商品名称');
                return false;
            }
            return true;
        }

        var getList = function () {
            if (isEnd || isLoading) return;
            isLoading = true;
            page += 1;
            console.log('当前'+page);
            $.ajax({
                type:'get',
                async:false,
                url:'/page.php?page='+ page,
                dataType:'html',
                success:function (ret) {
                    var html = document.getElementById("pro-list").innerHTML;
                    //再跟你想追加的代码加到一起插入div中
                    document.getElementById("pro-list").innerHTML = html + ret;
                    isLoading = false;
                    loading.style.display = 'none';
                    if (page === 10 || ret.length === 0) {
                        isEnd = true;
                        document.getElementById('load-animation').style.display = 'none';
                        document.getElementById('load-string').innerHTML = '数据加载完毕';
                    }
                },
                error:function (err) {
                    isEnd = true;
                    document.getElementById('load-animation').style.display = 'none';
                    document.getElementById('load-string').innerHTML = '数据加载完毕';
                }
            })
        };

        $(window).bind('scroll',function () {
            loading.style.display = 'block';
            if($(window).scrollTop()+$(window).height() >= $(document).height()) {
                getList();
            }
        });

        function setRem(){
            var width = document.body.offsetWidth;
            var nowFont=width / 375. * 16.;
            var htmlFont=document.getElementsByTagName('html')[0];
            htmlFont.style.fontSize =nowFont+"px";
        }
        setRem();
        window.onresize=setRem;  //监听屏幕变化




    </script>
</body>
</html>